import Mock from 'mockjs'

var msg = Mock.mock({
  'list|50': [{
    'id|+1': 1,
    'markId|+1': 1,
    title: '消息@id',
    creater: '@cname()',
    create_time: '@date(yyyy-MM-dd hh:mm:ss)',
    msgTitle: "@cword(2, 10)",
    'classify|1': ['单据消息', '系统消息', '任务消息'],
    'read|1': [true, false],
    content: "@csentence(0,50)'"
  }]
})
export default [

  // 消息管理分页
  {
    url: '/task/msg/getPageList',
    type: 'post',
    response: config => {
      let { pageSize = 10, currentPage = 1 } = config.body
      const total = msg.list.length
      let list = msg.list.slice(pageSize * (currentPage - 1), currentPage * pageSize)
      return {
        code: 20000,
        data: {
          list,
          currentPage,
          pageSize,
          totalCount: total,
          totalPages: (total + pageSize - 1) / pageSize,
        }
      }
    }
  },
  // 消息管理删除
  {
    url: '/task/msg/del',
    type: 'post',
    response: config => {
      const { id } = config.body
      if (!id) {
        return {
          code: 403,
          msg: '删除失败',
          data: null
        }
      }
      return {
        code: 20000,
        msg: '处理成功',
        data: id
      }
    }
  },
]